<template>
  <t-space direction="vertical" style="width: 100%">
    <!-- 施工阶段 -->
    <t-steps v-model:current="engineeringDetails.currentStage" @change="handleChange">
      <t-step-item
        v-for="_ in dictionaryStore.get('engineering_stage')"
        :key="_.value"
        :title="_.label"
        :value="_.value"
        :content="analysisEnginerringTime(_.value)"
      />
    </t-steps>
    <t-divider  v-if="engineeringDetails.isProduct!='0'"></t-divider>
    <!-- 产品阶段 -->
    <t-steps
      :default-current="engineeringDetails.productStage"
      v-if="engineeringDetails.isProduct!='0'"
      readonly
    >
      <t-step-item
        v-for="_ in dictionaryStore.get('zheng_product_stage')"
        :key="_.value"
        :title="_.label"
        :value="_.value"
        :content="analysisTime(_.value)"
      />
    </t-steps>
   
  </t-space>
</template>

<script setup lang="ts">
import dayjs from 'dayjs';
import { inject, Ref } from 'vue';

import { useDictionaryStore } from '@/store';

// 字典仓库
const dictionaryStore = useDictionaryStore();
// 订单详情
const engineeringDetails = inject<Ref<Record<string, any>>>('engineeringDetails');
// 解析时间
const analysisTime = (keysString: any) => {
  console.log(keysString,'kkkk');
  
  if (!keysString) return '';
  let {productStageTimeMap} = engineeringDetails.value;
  let time = productStageTimeMap
  time=productStageTimeMap[keysString]
  return typeof time === 'number' ? dayjs(time).format('YYYY-MM-DD HH:mm:ss') : '';
};
const analysisEnginerringTime = (keysString: any) => {
  
  if (!keysString) return '';
  let {engineeringStageTimeMap} = engineeringDetails.value;
  let time = engineeringStageTimeMap
  time=engineeringStageTimeMap[keysString]?engineeringStageTimeMap[keysString]:{}
  if (time.startTime && time.endTime) {
    return `${time.startTime}-\n${time.endTime}`;
  }
  if (time.startTime) {
    if(typeof time.startTime === 'number') return dayjs(time.startTime).format('YYYY-MM-DD HH:mm:ss')
    return time.startTime+'-';
  }

  return '';
};
// 处理改变
const handleChange = (current: string | number, previous: string | number) => {
  if (current > engineeringDetails.value.stage) engineeringDetails.value.currentStage = previous;
};
</script>
<style lang="less" scoped>
:deep(.t-steps .t-steps-item__description) {
  font-size: 11px;
  color:#333;
  white-space: pre;
}
:deep(.t-divider) {
  margin: 6px 0;
}
</style>
